package pack4;

import java.util.LinkedList;
import java.util.Queue;

class RecentCounter {
    private Queue<Integer> queue;

    public RecentCounter() {
        queue = new LinkedList<>();
    }

    public int ping(Integer t) {
        if (t == null) {
            return 0;
        }
            queue.offer(t);
            while (queue.peek() != null && queue.peek() < t - 3000) {
                queue.poll();

        }
        return queue.size();
    }

    public static void main(String[] args) {
        RecentCounter counter = new RecentCounter();
        System.out.print("[");
        if(counter.ping(null)==0)
        System.out.print("NULL"+",");
        System.out.print(counter.ping(1)+",");
        System.out.print(counter.ping(100)+",");
        System.out.print(counter.ping(3001)+",");
        System.out.print(counter.ping(3002));
        System.out.print("]");

    }
}